﻿'*******************************************************************
' Program: Data Center Visio Rack Tool
' Author: Albert E Edlund
' Date:
'
' Purpose:
'*******************************************************************

Imports Microsoft.Practices.EnterpriseLibrary.Common
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging


Imports System
Imports System.Data

Imports System.Data.Common
Imports System.Windows
Imports System.Windows.Forms


Imports DC_Rack.Objects
Imports DC_Rack.Objects.clsDC_RackData
Imports DC_Rack.Objects.clsDC_RackReporting


Public Class frmRawDataEdit


#Region "Properties and definitions "


    Private m_db As Database
    Private m_ds As DataSet
    Private m_dt As DataTable
    Private m_sql As String

    '
    ' the location information
    '
    Private m_clsLocations As DC_Rack.Objects.clsLocations = Nothing
    Private m_clsattrLoc As DC_Rack.Objects.clsAttrLocation = Nothing
    Private m_clsCabinetRows As DC_Rack.Objects.clsAttrCabinetRows = Nothing
    Private m_clsattrGeoData As DC_Rack.Objects.clsAttrGeoData = Nothing
    Private m_clsClients As DC_Rack.Objects.clsClients = Nothing
    Private m_clsAttrCabinet As DC_Rack.Objects.clsAttrCabinet = Nothing

    '
    ' things that concern "connectivitiy"
    '
    Private m_clsNetworkLinks As DC_Rack.Objects.clsNetworkLinks = Nothing
    Private m_clsAttrNet As DC_Rack.Objects.clsAttrNetwork = Nothing
    Private m_clsattrPortData As DC_Rack.Objects.clsAttrPortData = Nothing

    '
    ' miscellaneous/base definitions
    '
    Private m_clsProductData As DC_Rack.Objects.clsProductData = Nothing
    Private m_clsAttrAsset As DC_Rack.Objects.clsAttrAsset = Nothing
    Private m_clsComponents As DC_Rack.Objects.clsComponents = Nothing
    Private m_clsCompHierarchy As DC_Rack.Objects.clsCompHierarchy = Nothing
    Private m_clsAttrDraw As DC_Rack.Objects.clsAttrDraw = Nothing
    Private m_clsDGMasters As DC_Rack.Objects.clsDgMasters = Nothing

    '
    ' disk storage
    '
    Private m_clsattrES As DC_Rack.Objects.clsAttrDiskES = Nothing
    Private m_clsattrDiskPhysical As DC_Rack.Objects.clsAttrDiskPhysical = Nothing
    Private m_clsattrDiskLogical As DC_Rack.Objects.clsAttrDiskLogical = Nothing

    '
    ' applications
    '
    Private m_clsattrApplication As DC_Rack.Objects.clsAttrApplications = Nothing
    Private m_clsappsolution As DC_Rack.Objects.clsAppSolutions = Nothing
    Private m_clsappconnections As DC_Rack.Objects.clsAppConnections = Nothing
    Private m_clsattrOS As DC_Rack.Objects.clsAttrOperatingSystem = Nothing
    Private m_clsattrVH As DC_Rack.Objects.clsAttrVirtualHost = Nothing
    Private m_clsattrProcessor As DC_Rack.Objects.clsAttrProcessor = Nothing

    '
    ' topology 
    '
    Private m_clstopoedge As DC_Rack.Objects.clsTopoEdge
    Private m_clstopopoint As DC_Rack.Objects.clsTopoPoint = Nothing
    Private m_clsslotmaster As DC_Rack.Objects.clsSlotMaster = Nothing
    Private m_clsportmaster As DC_Rack.Objects.clsPortMaster = Nothing

    ' height and width are really displacements
    Const constTabStartX As Integer = 20
    Const constTabStartY As Integer = 30
    Const constTabWidth As Integer = 60
    Const constTabHeight As Integer = 50

    Const constDGVStartX As Integer = 10
    Const constDGVStartY As Integer = 10
    Const constDGVWidth As Integer = 90
    Const constDGVHeight As Integer = 165

    '********* visio snippet vb.net vis0041vb ******************
    Private _drawingApplication As Microsoft.Office.Interop.Visio.Application
    Public Property drawingApplication() As Microsoft.Office.Interop.Visio.Application
        Get
            Return Me._drawingApplication
        End Get
        Set(ByVal value As Microsoft.Office.Interop.Visio.Application)
            If (value Is Nothing) Then
                Throw New System.ArgumentNullException("ApplicationValueIsNull", _
                    "drawingApplication is Null.")
            End If
            Me._drawingApplication = value
        End Set
    End Property

    '********* visio snippet vb.net vis0043vb ******************
    Private _drawingDocument As Microsoft.Office.Interop.Visio.Document
    Public Property drawingDocument() As Microsoft.Office.Interop.Visio.Document
        Get
            Return Me._drawingDocument
        End Get
        Set(ByVal value As Microsoft.Office.Interop.Visio.Document)
            If (value Is Nothing) Then
                Throw New System.ArgumentNullException("DocumentValueIsNull", _
                    "drawingDocument is Null.")
            End If
            Me._drawingDocument = value
        End Set
    End Property

    '********* visio snippet vb.net vis0045vb ******************
    Private _drawingWindow As Microsoft.Office.Interop.Visio.Window
    Public Property drawingWindow() As Microsoft.Office.Interop.Visio.Window
        Get
            Return Me._drawingWindow
        End Get
        Set(ByVal value As Microsoft.Office.Interop.Visio.Window)
            If (value Is Nothing) Then
                Throw New System.ArgumentNullException("WindowValueIsNull", _
                    "drawingWindow is Null.")
            End If
            Me._drawingWindow = value
        End Set
    End Property

    '********* visio snippet vb.net vis0044vb ******************
    Private _drawingPage As Microsoft.Office.Interop.Visio.Page
    Public Property drawingPage() As Microsoft.Office.Interop.Visio.Page
        Get
            Return Me._drawingPage
        End Get
        Set(ByVal value As Microsoft.Office.Interop.Visio.Page)
            If (value Is Nothing) Then
                Throw New System.ArgumentNullException("PageValueIsNull", _
                    "drawingPage is Null.")
            End If
            Me._drawingPage = value
        End Set
    End Property

  

#End Region

#Region " List Controls "

    '
    '
    '
    Private Sub lstPhysical_SelectedIndexChanged _
        (ByVal sender As System.Object, _
         ByVal e As System.EventArgs) _
         Handles lstPhysical.SelectedIndexChanged

        Me.StatusCurrentTable.Text = ""
        m_sql = ""
        Dim strTable As String = lstPhysical.SelectedItem.ToString

        Select Case strTable
            Case "Clients"
                m_sql = Objects.clsClients.readall
                Me.StatusCurrentTable.Text = DC_RackTables.tblClient.ToString
                Exit Select
            Case "CabinetRows"
                m_sql = Objects.clsAttrCabinetRows.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAttrCabinetRow.ToString
                Exit Select
            Case "Components"
                m_sql = Objects.clsComponents.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblComponents.ToString
                Exit Select

            Case "Locations"
                m_sql = Objects.clsLocations.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblLocation.ToString
                Exit Select
            Case "NetworkLinks"
                m_sql = Objects.clsNetworkLinks.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblNetworkLink.ToString
            Case "AttrLocation"
                m_sql = Objects.clsAttrLocation.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAttrLocation.ToString
                Exit Select
            Case "GeoData"
                m_sql = Objects.clsAttrGeoData.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAttrGeoData.ToString
                Exit Select
            Case "CabinetRows"
                m_sql = Objects.clsAttrCabinetRows.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAttrCabinetRow.ToString
                Exit Select
            Case "Cabinets"
                m_sql = Objects.clsAttrCabinet.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAttrCabinet.ToString
                Exit Select
            Case "ProductData"
                m_sql = Objects.clsProductData.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblProductData.ToString
                Exit Select
            Case "DGMasters"
                m_sql = Objects.clsDgMasters.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblDGMasters.ToString
                Exit Select


        End Select

        LoadDataGridView()

    End Sub

    '
    '
    '
    Private Sub lstMeta_SelectedIndexChanged _
        (ByVal sender As System.Object, _
         ByVal e As System.EventArgs) _
         Handles lstMeta.SelectedIndexChanged

        Me.StatusCurrentTable.Text = ""
        m_sql = ""
        Dim strTable As String = lstMeta.SelectedItem.ToString

        Select Case strTable
            Case "PortMaster"
                m_sql = Objects.clsPortMaster.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblPortMasterData.ToString
                Exit Select
            Case "SlotMaster"
                m_sql = Objects.clsSlotMaster.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblSlotMasterData.ToString
                Exit Select
            Case "ItemEdge"
                m_sql = Objects.clsTopoEdge.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblTopoEdge.ToString
                Exit Select
            Case "ItemPoint"
                m_sql = Objects.clsTopoPoint.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblTopoPoint.ToString
                Exit Select
            Case "CompHierarchy"
                m_sql = Objects.clsCompHierarchy.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblCompHierarchy.ToString
                Exit Select


        End Select

        LoadDataGridView()


    End Sub

    '
    '
    '
    Private Sub lstLogical_SelectedIndexChanged _
        (ByVal sender As System.Object, _
         ByVal e As System.EventArgs) _
         Handles lstLogical.SelectedIndexChanged


        Me.StatusCurrentTable.Text = ""
        m_sql = ""
        Dim strTable As String = lstLogical.SelectedItem.ToString

        Select Case strTable

            Case "OperatingSystem"
                m_sql = Objects.clsAttrOperatingSystem.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAttrOperatingSystem.ToString
                Exit Select
            Case "Application"
                m_sql = Objects.clsAttrApplications.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAttrApplication.ToString
                Exit Select
            Case "AppSolution"
                m_sql = Objects.clsAppSolutions.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAppSolution.ToString
                Exit Select
            Case "AppConnection"
                m_sql = Objects.clsAppConnections.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAppConnection.ToString
                Exit Select

            Case "Asset"
                m_sql = Objects.clsAttrAsset.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAttrAsset.ToString
                Exit Select

            Case "Processor"
                m_sql = Objects.clsAttrProcessor.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAttrProcessor.ToString
                Exit Select

            Case "PortData"
                m_sql = Objects.clsAttrPortData.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAttrPortData.ToString
                Exit Select
            Case "Network"
                m_sql = Objects.clsAttrNetwork.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAttrNetwork.ToString
                Exit Select


            Case "ExternalStorage"
                m_sql = Objects.clsAttrDiskES.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAttrExternalStorage.ToString
                Exit Select
            Case "DiskPhysical"
                m_sql = Objects.clsAttrDiskPhysical.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAttrDiskPhysical.ToString
                Exit Select
            Case "DiskLogical"
                m_sql = Objects.clsAttrDiskLogical.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAttrDiskLogical.ToString
                Exit Select

            Case "VirtualHosts"
                m_sql = Objects.clsAttrVirtualHost.readAll
                Me.StatusCurrentTable.Text = DC_RackTables.tblAttrVirtualHost.ToString
                Exit Select


        End Select

        LoadDataGridView()


    End Sub


    '
    ' these are view "tables" from the database
    '
    Private Sub lstViews_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstViews.SelectedIndexChanged

        Me.StatusCurrentTable.Text = ""
        m_sql = ""
        Dim strTable As String = lstViews.SelectedItem.ToString

        Const viewCabinets As String = "viewCabinetData"
        Const spcallviewcabinet As String = "selectViewCabinets"

        Const viewcomponentLocation As String = "viewComponent_Location"
        Const spcallviewcomponentLocation As String = "selectViewComponentLocation"

        Const viewcomponentNetwork As String = "viewComponentNetwork"
        Const spcallviewcomponentNetwork As String = "selectViewComponentNetwork"

        Const viewPortAnalysis As String = "viewPortAnalysis"
        Const spcallviewPortAnalysis As String = "selectViewPortAnalysis"

        Select Case strTable
            Case "ComponentAttrNetwork"
                m_sql = spcallviewcomponentNetwork
                Me.StatusCurrentTable.Text = viewcomponentNetwork
                Exit Select
            Case "ComponentAttrLocation"
                m_sql = spcallviewcomponentLocation
                Me.StatusCurrentTable.Text = viewcomponentLocation
                Exit Select
            Case "PortAnalysis"
                m_sql = spcallviewPortAnalysis
                Me.StatusCurrentTable.Text = viewPortAnalysis
                Exit Select
            Case "CabinetData"
                m_sql = spcallviewcabinet
                Me.StatusCurrentTable.Text = viewCabinets
                Exit Select
        End Select

        LoadDataGridView()




    End Sub


#End Region

#Region " get data "

    '
    '
    '
    Private Sub GetData()

        Try

            Me.Cursor = Cursors.WaitCursor

            ' default we can play with a table
            Me.StatusEditable.Text = "Editable"

            '
            ' if we don't specifically build the class then we do not have the ability to build a report on it
            '
            Select Case StatusCurrentTable.Text


                '
                ' things that anchor what we are moving
                '
                Case DC_RackTables.tblComponents.ToString
                    If m_clsComponents Is Nothing Then
                        m_clsComponents = New DC_Rack.Objects.clsComponents(drawingApplication, drawingDocument)
                    Else
                        m_clsComponents = Nothing
                        m_clsComponents = New DC_Rack.Objects.clsComponents(drawingApplication, drawingDocument)
                    End If
                    m_clsComponents.dbSelectAllComponents()
                    Me.BindingSource1.DataSource = m_clsComponents.m_dt

                Case DC_RackTables.tblDGMasters.ToString
                    If m_clsDGMasters Is Nothing Then
                        m_clsDGMasters = New DC_Rack.Objects.clsDgMasters(False)
                    Else
                        m_clsDGMasters = Nothing
                        m_clsDGMasters = New DC_Rack.Objects.clsDgMasters(False)
                    End If
                    m_clsDGMasters.dbSelectAllDGMasters()
                    Me.BindingSource1.DataSource = m_clsDGMasters.m_dt

                Case DC_RackTables.tblProductData.ToString
                    If m_clsProductData Is Nothing Then
                        m_clsProductData = New DC_Rack.Objects.clsProductData
                    Else
                        m_clsProductData = Nothing
                        m_clsProductData = New DC_Rack.Objects.clsProductData
                    End If
                    m_clsProductData.dbSelectAllProducts()
                    Me.BindingSource1.DataSource = m_clsProductData.m_dt


                    '
                    ' how are the components linked together
                    '
                Case DC_RackTables.tblNetworkLink.ToString
                    If m_clsNetworkLinks Is Nothing Then
                        m_clsNetworkLinks = New DC_Rack.Objects.clsNetworkLinks(drawingApplication, drawingDocument)
                    Else
                        m_clsNetworkLinks = Nothing
                        m_clsNetworkLinks = New DC_Rack.Objects.clsNetworkLinks(drawingApplication, drawingDocument)
                    End If
                    m_clsNetworkLinks.dbSelectAllNetworkLinks()
                    Me.BindingSource1.DataSource = m_clsNetworkLinks.m_dt

                Case DC_RackTables.tblAttrNetwork.ToString
                    If m_clsAttrNet Is Nothing Then
                        m_clsAttrNet = New DC_Rack.Objects.clsAttrNetwork(drawingApplication, drawingDocument)
                    Else
                        m_clsAttrNet = Nothing
                        m_clsAttrNet = New DC_Rack.Objects.clsAttrNetwork(drawingApplication, drawingDocument)
                    End If
                    m_clsAttrNet.dbSelectAllNetworkData()
                    Me.BindingSource1.DataSource = m_clsAttrNet.m_dt

                Case DC_RackTables.tblAttrPortData.ToString
                    If m_clsattrPortData Is Nothing Then
                        m_clsattrPortData = New DC_Rack.Objects.clsAttrPortData(drawingApplication, drawingDocument)
                    Else
                        m_clsattrPortData = Nothing
                        m_clsattrPortData = New DC_Rack.Objects.clsAttrPortData(drawingApplication, drawingDocument)
                    End If
                    m_clsattrPortData.dbSelectAllPortData()
                    Me.BindingSource1.DataSource = m_clsattrPortData.m_dt

                    '
                    ' things that help us understand where everything is at
                    '

                Case DC_RackTables.tblClient.ToString
                    If m_clsClients Is Nothing Then
                        m_clsClients = New DC_Rack.Objects.clsClients
                    Else
                        m_clsClients = Nothing
                        m_clsClients = New DC_Rack.Objects.clsClients
                    End If
                    m_clsClients.dbSelectAllClients()
                    Me.BindingSource1.DataSource = m_clsClients.m_dt

                Case DC_RackTables.tblLocation.ToString
                    If m_clsLocations Is Nothing Then
                        m_clsLocations = New DC_Rack.Objects.clsLocations
                    Else
                        m_clsLocations = Nothing
                        m_clsLocations = New DC_Rack.Objects.clsLocations
                    End If
                    m_clsLocations.dbSelectAllLocations()
                    Me.BindingSource1.DataSource = m_clsLocations.m_dt

                Case DC_RackTables.tblAttrLocation.ToString
                    If m_clsattrLoc Is Nothing Then
                        m_clsattrLoc = New DC_Rack.Objects.clsAttrLocation(drawingApplication, drawingDocument)
                    Else
                        m_clsattrLoc = Nothing
                        m_clsattrLoc = New DC_Rack.Objects.clsAttrLocation(drawingApplication, drawingDocument)
                    End If
                    m_clsattrLoc.dbSelectAllAttrLocation()
                    Me.BindingSource1.DataSource = m_clsattrLoc.m_dt

                Case DC_RackTables.tblAttrGeoData.ToString
                    If m_clsattrGeoData Is Nothing Then
                        m_clsattrGeoData = New DC_Rack.Objects.clsAttrGeoData
                    Else
                        m_clsattrGeoData = Nothing
                        m_clsattrGeoData = New DC_Rack.Objects.clsAttrGeoData
                    End If
                    m_clsattrGeoData.dbSelectAllGeoData()
                    Me.BindingSource1.DataSource = m_clsattrGeoData.m_dt

                Case DC_RackTables.tblAttrCabinetRow.ToString
                    If m_clsCabinetRows Is Nothing Then
                        m_clsCabinetRows = New DC_Rack.Objects.clsAttrCabinetRows
                    Else
                        m_clsCabinetRows = Nothing
                        m_clsCabinetRows = New DC_Rack.Objects.clsAttrCabinetRows
                    End If
                    m_clsCabinetRows.dbSelectAllCabinetRows()
                    Me.BindingSource1.DataSource = m_clsCabinetRows.m_dt

                Case DC_RackTables.tblAttrCabinet.ToString
                    If m_clsAttrCabinet Is Nothing Then
                        m_clsAttrCabinet = New DC_Rack.Objects.clsAttrCabinet
                    Else
                        m_clsAttrCabinet = Nothing
                        m_clsAttrCabinet = New DC_Rack.Objects.clsAttrCabinet
                    End If
                    m_clsAttrCabinet.dbSelectAllCabinets()
                    Me.BindingSource1.DataSource = m_clsAttrCabinet.m_dt



                    '
                    ' things that describe attributes of what we are tracking
                    '

                Case DC_RackTables.tblAttrAsset.ToString
                    If m_clsAttrAsset Is Nothing Then
                        m_clsAttrAsset = New DC_Rack.Objects.clsAttrAsset
                    Else
                        m_clsAttrAsset = Nothing
                        m_clsAttrAsset = New DC_Rack.Objects.clsAttrAsset
                    End If
                    m_clsAttrAsset.dbSelectAllAssets()
                    Me.BindingSource1.DataSource = m_clsAttrAsset.m_dt

                    '
                    ' how do we track applications 
                    '
                Case DC_RackTables.tblAttrOperatingSystem.ToString
                    If m_clsattrOS Is Nothing Then
                        m_clsattrOS = New DC_Rack.Objects.clsAttrOperatingSystem(drawingApplication, drawingDocument)
                    Else
                        m_clsattrOS = Nothing
                        m_clsattrOS = New DC_Rack.Objects.clsAttrOperatingSystem(drawingApplication, drawingDocument)
                    End If
                    m_clsattrOS.dbSelectAllOperatingSystems()
                    Me.BindingSource1.DataSource = m_clsattrOS.m_dt

                Case DC_RackTables.tblAttrApplication.ToString
                    If m_clsattrApplication Is Nothing Then
                        m_clsattrApplication = New DC_Rack.Objects.clsAttrApplications(drawingApplication, drawingDocument)
                    Else
                        m_clsattrApplication = Nothing
                        m_clsattrApplication = New DC_Rack.Objects.clsAttrApplications(drawingApplication, drawingDocument)
                    End If
                    m_clsattrApplication.dbSelectAllApplications()
                    Me.BindingSource1.DataSource = m_clsattrApplication.m_dt

                Case DC_RackTables.tblAttrProcessor.ToString
                    If m_clsattrProcessor Is Nothing Then
                        m_clsattrProcessor = New DC_Rack.Objects.clsAttrProcessor(drawingApplication, drawingDocument)
                    Else
                        m_clsattrProcessor = Nothing
                        m_clsattrProcessor = New DC_Rack.Objects.clsAttrProcessor(drawingApplication, drawingDocument)
                    End If
                    m_clsattrProcessor.dbSelectAllProcessor()
                    Me.BindingSource1.DataSource = m_clsattrProcessor.m_dt

                Case DC_RackTables.tblAttrVirtualHost.ToString
                    If m_clsattrVH Is Nothing Then
                        m_clsattrVH = New DC_Rack.Objects.clsAttrVirtualHost(drawingApplication, drawingDocument)
                    Else
                        m_clsattrVH = Nothing
                        m_clsattrVH = New DC_Rack.Objects.clsAttrVirtualHost(drawingApplication, drawingDocument)
                    End If
                    m_clsattrVH.dbSelectAllVirtualHosts()
                    Me.BindingSource1.DataSource = m_clsattrVH.m_dt


                    '
                    ' disk storage section to support some san parameters
                    '
                Case DC_RackTables.tblAttrExternalStorage.ToString
                    If m_clsattrES Is Nothing Then
                        m_clsattrES = New DC_Rack.Objects.clsAttrDiskES(drawingApplication, drawingDocument)
                    Else
                        m_clsattrES = Nothing
                        m_clsattrES = New DC_Rack.Objects.clsAttrDiskES(drawingApplication, drawingDocument)
                    End If
                    m_clsattrES.dbSelectAllExternalStorage()
                    Me.BindingSource1.DataSource = m_clsattrES.m_dt

                Case DC_RackTables.tblAttrDiskLogical.ToString
                    If m_clsattrDiskLogical Is Nothing Then
                        m_clsattrDiskLogical = New DC_Rack.Objects.clsAttrDiskLogical(drawingApplication, drawingDocument)
                    Else
                        m_clsattrDiskLogical = Nothing
                        m_clsattrDiskLogical = New DC_Rack.Objects.clsAttrDiskLogical(drawingApplication, drawingDocument)
                    End If
                    m_clsattrDiskLogical.dbSelectAllDiskLogical()
                    Me.BindingSource1.DataSource = m_clsattrDiskLogical.m_dt

                Case DC_RackTables.tblAttrDiskPhysical.ToString
                    If m_clsattrDiskPhysical Is Nothing Then
                        m_clsattrDiskPhysical = New DC_Rack.Objects.clsAttrDiskPhysical(drawingApplication, drawingDocument)
                    Else
                        m_clsattrDiskPhysical = Nothing
                        m_clsattrDiskPhysical = New DC_Rack.Objects.clsAttrDiskPhysical(drawingApplication, drawingDocument)
                    End If
                    m_clsattrDiskPhysical.dbSelectAllDiskPhysical()
                    Me.BindingSource1.DataSource = m_clsattrDiskPhysical.m_dt


                Case Else


                    If m_ds Is Nothing Then
                        m_ds = New DataSet
                    Else
                        m_ds = Nothing
                        m_ds = New DataSet
                    End If
                    m_ds.SchemaSerializationMode = SchemaSerializationMode.IncludeSchema

                    If m_dt Is Nothing Then
                        m_dt = New DataTable
                    Else
                        m_dt = Nothing
                        m_dt = New DataTable
                    End If

                    If m_sql <> "" Then
                        Dim cmd As DbCommand = m_db.GetStoredProcCommand(m_sql)
                        m_ds = m_db.ExecuteDataSet(cmd)
                        m_dt = m_ds.Tables.Item(0)
                    End If

                    Me.StatusEditable.Text = "Not Editable"
                    Me.BindingSource1.DataSource = m_dt

            End Select

            If Me.StatusEditable.Text = "Editable" Then
                Me.ToolStripUpdateRecord.Enabled = True
                Me.BindingNavigatorAddNewItem.Enabled = True
                Me.BindingNavigatorDeleteItem.Enabled = True
            Else
                Me.ToolStripUpdateRecord.Enabled = False
                Me.BindingNavigatorAddNewItem.Enabled = False
                Me.BindingNavigatorDeleteItem.Enabled = False
            End If



            'Dim strTable As String = m_ds.Tables.Item(0).TableName.ToString
            'Dim intCols As Integer = m_dt.Columns.Count
            'Dim intRows As Integer = m_dt.Rows.Count

            ' Resize the DataGridView columns to fit the newly loaded content.
            Me.DataGridView1.AutoResizeColumns( _
                DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader)


        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            Me.StatusCurrentTable.Text = ""
            If (rethrow) Then
                Throw
            End If
        Finally
            Me.Cursor = Cursors.Default
        End Try

        Me.Cursor = Cursors.Default

    End Sub

    '
    '
    '
    Private Sub LoadDataGridView()

        ' Bind the DataGridView to the BindingSource
        ' and load the data from the database.
        Me.BindingNavigator1.BindingSource = Me.BindingSource1
        Me.BindingNavigatorAddNewItem.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText
        Me.BindingNavigatorDeleteItem.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText
        Me.DataGridView1.DataSource = Me.BindingSource1

        Try

            ' get rid of existing objects
            clearTableClasses()

            If StatusCurrentTable.Text = "" _
                Or m_sql = "" Then
                ' just in case 
                Me.ToolStripUpdateRecord.Enabled = False
                Me.BindingNavigatorAddNewItem.Enabled = False
                Me.BindingNavigatorDeleteItem.Enabled = False
                Me.StatusEditable.Text = "Not Editable"
                Exit Sub
            End If

            GetData()

            TabControl1.SelectedIndex = 1

        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Notify Policy")
            If (rethrow) Then
                Throw
            End If
        End Try


    End Sub


#End Region

#Region " Form Events "




    Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click

        Me.Close()

    End Sub


    '
    '
    '
    Private Sub TabControl1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.Resize

        Try

            Dim locStart As System.Drawing.Point
            locStart.X = constDGVStartX
            locStart.Y = constDGVStartY
            Me.DataGridView1.Location = locStart
            Me.DataGridView1.Width = TabControl1.Width - constDGVWidth
            Me.DataGridView1.Height = TabControl1.Height - constDGVHeight

        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                ' throw original exception
                Throw
            End If
        End Try

    End Sub

    '
    '
    '
    Private Sub frmDataMain_ResizeEnd(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ResizeEnd

        Try

            Dim locStart As System.Drawing.Point
            locStart.X = constTabStartX
            locStart.Y = constTabStartY + Me.BindingNavigator1.Height
            Me.TabControl1.Location = locStart

            Me.TabControl1.Width = Me.Width - constTabWidth
            Me.TabControl1.Height = Me.Height - BindingNavigator1.Height _
                        - StatusStrip1.Height - MenuStrip1.Height - constTabHeight

            locStart.X = constDGVStartX
            locStart.Y = constDGVStartY
            Me.DataGridView1.Location = locStart
            Me.DataGridView1.Width = Me.Width - constDGVWidth
            Me.DataGridView1.Height = Me.Height - constDGVHeight


        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                ' throw original exception
                Throw
            End If
        End Try

    End Sub

#End Region

#Region " Update / clear  tables "

    '
    '
    '
    Private Sub ToolStripUpdateRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripUpdateRecord.Click
        updateLoadedTable()
    End Sub

    '
    '
    '
    Private Sub UpdateTableToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles UpdateTableToolStripMenuItem.Click
        updateLoadedTable()
    End Sub

    '
    ' take the active data class and update the rows, return a count of rows affected
    '
    Private Sub updateLoadedTable()
        Try
            Dim rowsAffected As Int16 = 0

            If StatusCurrentTable.Text <> "" _
                And LCase(Me.StatusEditable.Text) = "editable" Then

                'commit changes
                Me.Validate()
                BindingSource1.EndEdit()

                Select Case StatusCurrentTable.Text


                    '
                    '*********************************************************************
                    ' location data
                    ' geodata will not currently be editable
                    '
                    Case DC_RackTables.tblClient.ToString
                        If Not (m_clsClients Is Nothing) Then
                            rowsAffected = m_clsClients.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblLocation.ToString
                        If Not (m_clsLocations.m_ds Is Nothing) Then
                            rowsAffected = m_clsLocations.dbUpdateDataSet()
                        End If
                    Case DC_RackTables.tblAttrLocation.ToString
                        If Not (m_clsattrLoc Is Nothing) Then
                            rowsAffected = m_clsattrLoc.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblAttrCabinetRow.ToString
                        If Not (m_clsCabinetRows Is Nothing) Then
                            rowsAffected = m_clsCabinetRows.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblAttrCabinet.ToString
                        If Not (m_clsAttrCabinet Is Nothing) Then
                            rowsAffected = m_clsAttrCabinet.dbUpdateDataSet
                        End If

                        '
                        '*********************************************************************
                        ' miscellaneous and base data
                        ' comphierarchy will not currently be editable
                        '
                    Case DC_RackTables.tblComponents.ToString
                        If Not (m_clsComponents Is Nothing) Then
                            rowsAffected = m_clsComponents.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblProductData.ToString
                        If Not (m_clsProductData Is Nothing) Then
                            rowsAffected = m_clsProductData.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblAttrAsset.ToString
                        If Not (m_clsAttrAsset Is Nothing) Then
                            rowsAffected = m_clsAttrAsset.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblAttrDraw.ToString
                        If Not (m_clsAttrDraw Is Nothing) Then
                            rowsAffected = m_clsAttrDraw.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblDGMasters.ToString
                        If Not (m_clsDGMasters Is Nothing) Then
                            rowsAffected = m_clsDGMasters.dbUpdateDataSet
                        End If

                        '
                        '*********************************************************************
                        ' application data
                        '
                    Case DC_RackTables.tblAttrOperatingSystem.ToString
                        If Not (m_clsattrOS Is Nothing) Then
                            rowsAffected = m_clsattrOS.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblAttrApplication.ToString
                        If Not (m_clsattrApplication Is Nothing) Then
                            rowsAffected = m_clsattrApplication.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblAppConnection.ToString
                        If Not (m_clsappconnections Is Nothing) Then
                            rowsAffected = m_clsappconnections.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblAppSolution.ToString
                        If Not (m_clsappsolution Is Nothing) Then
                            rowsAffected = m_clsappsolution.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblAttrVirtualHost.ToString
                        If Not (m_clsattrVH Is Nothing) Then
                            rowsAffected = m_clsattrVH.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblAttrProcessor.ToString
                        If Not (m_clsattrProcessor Is Nothing) Then
                            rowsAffected = m_clsattrProcessor.dbUpdateDataSet
                        End If

                        '
                        '*********************************************************************
                        ' network data
                        '
                    Case DC_RackTables.tblAttrPortData.ToString
                        If Not (m_clsattrPortData Is Nothing) Then
                            rowsAffected = m_clsattrPortData.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblAttrNetwork.ToString
                        If Not (m_clsAttrNet Is Nothing) Then
                            rowsAffected = m_clsAttrNet.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblNetworkLink.ToString
                        If Not (m_clsNetworkLinks Is Nothing) Then
                            rowsAffected = m_clsNetworkLinks.dbUpdateDataSet
                        End If

                        '
                        '*********************************************************************
                        ' disk data
                        '
                    Case DC_RackTables.tblAttrExternalStorage.ToString
                        If Not (m_clsattrES Is Nothing) Then
                            rowsAffected = m_clsattrES.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblAttrDiskPhysical.ToString
                        If Not (m_clsattrDiskPhysical Is Nothing) Then
                            rowsAffected = m_clsattrDiskPhysical.dbUpdateDataSet
                        End If
                    Case DC_RackTables.tblAttrDiskLogical.ToString
                        If Not (m_clsattrDiskLogical Is Nothing) Then
                            rowsAffected = m_clsattrDiskLogical.dbUpdateDataSet
                        End If
                End Select

                MsgBox("update " & StatusCurrentTable.Text & " (" & rowsAffected.ToString & ")")

            End If

        Catch sql As SqlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch err As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(err, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If

        End Try

    End Sub



    '
    ' these are the tables that we allow to be edited, so we should use the class
    ' calls
    '
    Private Sub clearTableClasses()

        Try

            '
            '*********************************************************************
            ' location data
            '
            If Not (m_clsClients Is Nothing) Then
                m_clsClients = Nothing
            End If
            If Not (m_clsLocations.m_ds Is Nothing) Then
                m_clsLocations = Nothing
            End If
            If Not (m_clsattrLoc Is Nothing) Then
                m_clsattrLoc = Nothing
            End If
            If Not (m_clsCabinetRows Is Nothing) Then
                m_clsCabinetRows = Nothing
            End If
            If Not (m_clsAttrCabinet Is Nothing) Then
                m_clsAttrCabinet = Nothing
            End If
            If Not (m_clsattrGeoData Is Nothing) Then
                m_clsattrGeoData = Nothing
            End If

            '
            '*********************************************************************
            ' miscellaneous and base data
            '
            If Not (m_clsComponents Is Nothing) Then
                m_clsComponents = Nothing
            End If
            If Not (m_clsCompHierarchy Is Nothing) Then
                m_clsCompHierarchy = Nothing
            End If
            If Not (m_clsProductData Is Nothing) Then
                m_clsProductData = Nothing
            End If
            If Not (m_clsAttrAsset Is Nothing) Then
                m_clsAttrAsset = Nothing
            End If
            If Not (m_clsAttrDraw Is Nothing) Then
                m_clsAttrDraw = Nothing
            End If
            If Not (m_clsDGMasters Is Nothing) Then
                m_clsDGMasters = Nothing
            End If

            '
            '*********************************************************************
            ' application data
            '
            If Not (m_clsattrOS Is Nothing) Then
                m_clsattrOS = Nothing
            End If
            If Not (m_clsattrApplication Is Nothing) Then
                m_clsattrApplication = Nothing
            End If
            If Not (m_clsappconnections Is Nothing) Then
                m_clsappconnections = Nothing
            End If
            If Not (m_clsappsolution Is Nothing) Then
                m_clsappsolution = Nothing
            End If
            If Not (m_clsattrVH Is Nothing) Then
                m_clsattrVH = Nothing
            End If
            If Not (m_clsattrProcessor Is Nothing) Then
                m_clsattrProcessor = Nothing
            End If

            '
            '*********************************************************************
            ' network data
            '
            If Not (m_clsattrPortData Is Nothing) Then
                m_clsattrPortData = Nothing
            End If
            If Not (m_clsAttrNet Is Nothing) Then
                m_clsAttrNet = Nothing
            End If
            If Not (m_clsNetworkLinks Is Nothing) Then
                m_clsNetworkLinks = Nothing
            End If

            '
            '*********************************************************************
            ' disk data
            '
            If Not (m_clsattrES Is Nothing) Then
                m_clsattrES = Nothing
            End If
            If Not (m_clsattrDiskPhysical Is Nothing) Then
                m_clsattrDiskPhysical = Nothing
            End If
            If Not (m_clsattrDiskLogical Is Nothing) Then
                m_clsattrDiskLogical = Nothing
            End If


        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try



    End Sub



#End Region

#Region " constructor "

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        Try
            ' Add any initialization after the InitializeComponent() call.

            m_db = DatabaseFactory.CreateDatabase()


            Dim locStart As System.Drawing.Point
            locStart.X = constTabStartX
            locStart.Y = constTabStartY + Me.BindingNavigator1.Height
            Me.TabControl1.Location = locStart

            Me.TabControl1.Width = Me.Width - constTabWidth
            Me.TabControl1.Height = Me.Height - BindingNavigator1.Height _
                        - StatusStrip1.Height - MenuStrip1.Height - constTabHeight


            locStart.X = constDGVStartX
            locStart.Y = constDGVStartY
            Me.DataGridView1.Location = locStart
            Me.DataGridView1.Width = Me.Width - constDGVWidth
            Me.DataGridView1.Height = Me.Height - constDGVHeight

            Me.ToolStripUpdateRecord.Enabled = False
            Me.BindingNavigatorAddNewItem.Enabled = False
            Me.BindingNavigatorDeleteItem.Enabled = False

        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                ' throw original exception
                Throw
            End If
        End Try
    End Sub






    Protected Overrides Sub Finalize()

        clearTableClasses()
        If Not (m_ds Is Nothing) Then
            m_ds = Nothing
        End If
        If Not (m_dt Is Nothing) Then
            m_dt = Nothing
        End If

        MyBase.Finalize()

    End Sub

#End Region


    Private Sub ReportToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReportToolStripMenuItem.Click


        '
        ' 
        '
        Try

            Dim rptType As clsDC_RackReporting.baseReports = baseReports.rptUnknown
            Dim dtReport As System.Data.DataTable = Nothing

            Select Case StatusCurrentTable.Text


                '
                '*********************************************************************
                ' location data
                ' geodata will not currently be editable
                '
                Case DC_RackTables.tblClient.ToString
                    If Not (m_clsClients Is Nothing) Then
                        rptType = baseReports.rptClientsAll
                        dtReport = m_clsClients.m_ds.Tables(DC_RackTables.tblClient.ToString)
                    End If
                Case DC_RackTables.tblLocation.ToString
                    If Not (m_clsLocations.m_ds Is Nothing) Then
                        rptType = baseReports.rptLocationsAll
                        dtReport = m_clsLocations.m_ds.Tables(DC_RackTables.tblLocation.ToString)
                    End If
                Case DC_RackTables.tblAttrLocation.ToString
                    If Not (m_clsattrLoc Is Nothing) Then
                        rptType = baseReports.rptAttrLocationsAll
                        dtReport = m_clsattrLoc.m_ds.Tables(DC_RackTables.tblAttrLocation.ToString)
                    End If
                Case DC_RackTables.tblAttrCabinetRow.ToString
                    If Not (m_clsCabinetRows Is Nothing) Then
                        rptType = baseReports.rptCabinetRowsAll
                        dtReport = m_clsCabinetRows.m_ds.Tables(DC_RackTables.tblAttrCabinetRow.ToString)
                    End If
                Case DC_RackTables.tblAttrCabinet.ToString
                    If Not (m_clsAttrCabinet Is Nothing) Then
                        rptType = baseReports.rptAttrCabinetsAll
                        dtReport = m_clsAttrCabinet.m_ds.Tables(DC_RackTables.tblAttrCabinet.ToString)
                    End If

                    '
                    '*********************************************************************
                    ' miscellaneous and base data
                    ' comphierarchy will not currently be editable
                    '
                Case DC_RackTables.tblComponents.ToString
                    If Not (m_clsComponents Is Nothing) Then
                        rptType = baseReports.rptComponentsAll
                        dtReport = m_clsComponents.m_ds.Tables(DC_RackTables.tblComponents.ToString)
                    End If
                Case DC_RackTables.tblProductData.ToString
                    If Not (m_clsProductData Is Nothing) Then
                        rptType = baseReports.rptProductDataAll
                        dtReport = m_clsProductData.m_ds.Tables(DC_RackTables.tblProductData.ToString)
                    End If
                Case DC_RackTables.tblAttrAsset.ToString
                    If Not (m_clsAttrAsset Is Nothing) Then
                        rptType = baseReports.rptAssetAll
                        dtReport = m_clsAttrAsset.m_ds.Tables(DC_RackTables.tblAttrAsset.ToString)
                    End If
                Case DC_RackTables.tblAttrDraw.ToString
                    If Not (m_clsAttrDraw Is Nothing) Then
                        rptType = baseReports.rptAttrDrawAll
                        dtReport = m_clsAttrDraw.m_ds.Tables(DC_RackTables.tblAttrAsset.ToString)
                    End If
                Case DC_RackTables.tblDGMasters.ToString
                    If Not (m_clsDGMasters Is Nothing) Then
                        rptType = baseReports.rptDGMasters
                        dtReport = m_clsDGMasters.m_ds.Tables(DC_RackTables.tblDGMasters.ToString)
                    End If

                    '
                    '*********************************************************************
                    ' application data
                    '
                Case DC_RackTables.tblAttrOperatingSystem.ToString
                    If Not (m_clsattrOS Is Nothing) Then
                        rptType = baseReports.rptOSAll
                        dtReport = m_clsattrOS.m_ds.Tables(DC_RackTables.tblAttrOperatingSystem.ToString)

                    End If
                Case DC_RackTables.tblAttrApplication.ToString
                    If Not (m_clsattrApplication Is Nothing) Then
                        rptType = baseReports.rptApplicationsAll
                        dtReport = m_clsattrApplication.m_ds.Tables(DC_RackTables.tblAttrApplication.ToString)
                    End If
                Case DC_RackTables.tblAppConnection.ToString
                    If Not (m_clsappconnections Is Nothing) Then
                        rptType = baseReports.rptAppConnectionsAll
                        dtReport = m_clsappconnections.m_ds.Tables(DC_RackTables.tblAppConnection.ToString)
                    End If
                Case DC_RackTables.tblAppSolution.ToString
                    If Not (m_clsappsolution Is Nothing) Then
                        rptType = baseReports.rptAppSolutionsAll
                        dtReport = m_clsappsolution.m_ds.Tables(DC_RackTables.tblAppSolution.ToString)
                    End If
                Case DC_RackTables.tblAttrVirtualHost.ToString
                    If Not (m_clsattrVH Is Nothing) Then
                        rptType = baseReports.rptVHAll
                        dtReport = m_clsattrVH.m_ds.Tables(DC_RackTables.tblAttrVirtualHost.ToString)
                    End If
                Case DC_RackTables.tblAttrProcessor.ToString
                    If Not (m_clsattrProcessor Is Nothing) Then
                        rptType = baseReports.rptAttrProcessorsAll
                        dtReport = m_clsattrProcessor.m_ds.Tables(DC_RackTables.tblAttrProcessor.ToString)
                    End If

                    '
                    '*********************************************************************
                    ' network data
                    '
                Case DC_RackTables.tblAttrPortData.ToString
                    If Not (m_clsattrPortData Is Nothing) Then
                        rptType = baseReports.rptPortDataAll
                        dtReport = m_clsattrPortData.m_ds.Tables(DC_RackTables.tblAttrPortData.ToString)
                    End If
                Case DC_RackTables.tblAttrNetwork.ToString
                    If Not (m_clsAttrNet Is Nothing) Then
                        rptType = baseReports.rptAttrNetworkAll
                        dtReport = m_clsAttrNet.m_ds.Tables(DC_RackTables.tblAttrNetwork.ToString)
                    End If
                Case DC_RackTables.tblNetworkLink.ToString
                    If Not (m_clsNetworkLinks Is Nothing) Then
                        rptType = baseReports.rptNetworkLinksAll
                        dtReport = m_clsNetworkLinks.m_ds.Tables(DC_RackTables.tblNetworkLink.ToString)
                    End If

                    '
                    '*********************************************************************
                    ' disk data
                    '
                Case DC_RackTables.tblAttrExternalStorage.ToString
                    If Not (m_clsattrES Is Nothing) Then
                        rptType = baseReports.rptDiskESAll
                        dtReport = m_clsattrES.m_ds.Tables(DC_RackTables.tblAttrExternalStorage.ToString)
                    End If
                Case DC_RackTables.tblAttrDiskPhysical.ToString
                    If Not (m_clsattrDiskPhysical Is Nothing) Then
                        rptType = baseReports.rptDiskPhysicalsAll
                        dtReport = m_clsattrDiskPhysical.m_ds.Tables(DC_RackTables.tblAttrDiskPhysical.ToString)
                    End If
                Case DC_RackTables.tblAttrDiskLogical.ToString
                    If Not (m_clsattrDiskLogical Is Nothing) Then
                        rptType = baseReports.rptDiskLogicalsAll
                        dtReport = m_clsattrDiskLogical.m_ds.Tables(DC_RackTables.tblAttrDiskLogical.ToString)
                    End If

                Case Else
                    ' get out 
                    Exit Sub

            End Select


            If dtReport Is Nothing Then Exit Sub
            If rptType = baseReports.rptUnknown Then Exit Sub

            Dim frmReport As frmReportViewer = New frmReportViewer(rptType, dtReport)
            frmReport.ShowDialog()
            frmReport.Dispose()
            frmReport = Nothing

        Catch err As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(err, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub






End Class